using System;
using System.Collections.Generic;
using System.Text;
using System.IO;

namespace SideShow.Channel.Messages
{
    [Serializable]
    public abstract class Message : SerializableObject
    {
        private Guid _id;

        protected Message()
        {
        }

        public Message(Guid id)
        {
            _id = id;
        }

        public Guid Id
        {
            get { return _id; }
        }

        protected internal override void SerializeObject(BinaryWriter writer)
        {
            base.SerializeObject(writer);
            writer.Write(_id.ToByteArray());
        }

        protected internal override void DeserializeObject(BinaryReader reader)
        {
            base.DeserializeObject(reader);
            _id = new Guid(reader.ReadBytes(16));
        }
    }
}
